1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module adw.SplitButton; 26 27 private import adw.c.functions; 28 public import adw.c.types; 29 private import gio.MenuModel; 30 private import glib.ConstructionException; 31 private import glib.Str; 32 private import glib.c.functions; 33 private import gobject.ObjectG; 34 private import gobject.Signals; 35 private import gtk.AccessibleIF; 36 private import gtk.AccessibleT; 37 private import gtk.ActionableIF; 38 private import gtk.ActionableT; 39 private import gtk.BuildableIF; 40 private import gtk.BuildableT; 41 private import gtk.ConstraintTargetIF; 42 private import gtk.ConstraintTargetT; 43 private import gtk.Popover; 44 private import gtk.Widget; 45 private import std.algorithm; 46 47 48 /** 49 * A combined button and dropdown widget. 50 * 51 * <picture> 52 * <source srcset="split-button-dark.png" media="(prefers-color-scheme: dark)"> 53 * <img src="split-button.png" alt="split-button"> 54 * </picture> 55 * 56 * `AdwSplitButton` is typically used to present a set of actions in a menu, 57 * but allow access to one of them with a single click. 58 * 59 * The API is very similar to [class@Gtk.Button] and [class@Gtk.MenuButton], see 60 * their documentation for details. 61 * 62 * ## CSS nodes 63 * 64 * ``` 65 * splitbutton[.image-button][.text-button] 66 * ├── button 67 * │ ╰── <content> 68 * ├── separator 69 * ╰── menubutton 70 * ╰── button.toggle 71 * ╰── arrow 72 * ``` 73 * 74 * `AdwSplitButton`'s CSS node is called `splitbutton`. It contains the css 75 * nodes: `button`, `separator`, `menubutton`. See [class@Gtk.MenuButton] 76 * documentation for the `menubutton` contents. 77 * 78 * The main CSS node will contain the `.image-button` or `.text-button` style 79 * classes matching the button contents. The nested button nodes will never 80 * contain them. 81 * 82 * ## Accessibility 83 * 84 * `AdwSplitButton` uses the `GTK_ACCESSIBLE_ROLE_GROUP` role. 85 * 86 * Since: 1.0 87 */ 88 public class SplitButton : Widget, ActionableIF 89 { 90 /** the main Gtk struct */ 91 protected AdwSplitButton* adwSplitButton; 92 93 /** Get the main Gtk struct */ 94 public AdwSplitButton* getSplitButtonStruct(bool transferOwnership = false) 95 { 96 if (transferOwnership) 97 ownedRef = false; 98 return adwSplitButton; 99 } 100 101 /** the main Gtk struct as a void* */ 102 protected override void* getStruct() 103 { 104 return cast(void*)adwSplitButton; 105 } 106 107 /** 108 * Sets our main struct and passes it to the parent class. 109 */ 110 public this (AdwSplitButton* adwSplitButton, bool ownedRef = false) 111 { 112 this.adwSplitButton = adwSplitButton; 113 super(cast(GtkWidget*)adwSplitButton, ownedRef); 114 } 115 116 // add the Actionable capabilities 117 mixin ActionableT!(AdwSplitButton); 118 119 /** 120 * Gets the direction in which the popup will be popped up. 121 * 122 * Returns: the direction 123 * 124 * Since: 1.0 125 */ 126 public GtkArrowType getButtonDirection() 127 { 128 return adw_split_button_get_direction(adwSplitButton); 129 } 130 131 /** 132 */ 133 134 /** */ 135 public static GType getType() 136 { 137 return adw_split_button_get_type(); 138 } 139 140 /** 141 * Creates a new `AdwSplitButton`. 142 * 143 * Returns: the newly created `AdwSplitButton` 144 * 145 * Since: 1.0 146 * 147 * Throws: ConstructionException GTK+ fails to create the object. 148 */ 149 public this() 150 { 151 auto __p = adw_split_button_new(); 152 153 if(__p is null) 154 { 155 throw new ConstructionException("null returned by new"); 156 } 157 158 this(cast(AdwSplitButton*) __p); 159 } 160 161 /** 162 * Gets the child widget. 163 * 164 * Returns: the child widget 165 * 166 * Since: 1.0 167 */ 168 public Widget getChild() 169 { 170 auto __p = adw_split_button_get_child(adwSplitButton); 171 172 if(__p is null) 173 { 174 return null; 175 } 176 177 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p); 178 } 179 180 /** 181 * Gets the name of the icon used to automatically populate the button. 182 * 183 * If the icon name has not been set with [method@SplitButton.set_icon_name] 184 * the return value will be `NULL`. 185 * 186 * Returns: the icon name 187 * 188 * Since: 1.0 189 */ 190 public string getIconName() 191 { 192 return Str.toString(adw_split_button_get_icon_name(adwSplitButton)); 193 } 194 195 /** 196 * Gets the label for @self. 197 * 198 * Returns: the label for @self 199 * 200 * Since: 1.0 201 */ 202 public string getLabel() 203 { 204 return Str.toString(adw_split_button_get_label(adwSplitButton)); 205 } 206 207 /** 208 * Gets the menu model from which the popup will be created. 209 * 210 * Returns: the menu model 211 * 212 * Since: 1.0 213 */ 214 public MenuModel getMenuModel() 215 { 216 auto __p = adw_split_button_get_menu_model(adwSplitButton); 217 218 if(__p is null) 219 { 220 return null; 221 } 222 223 return ObjectG.getDObject!(MenuModel)(cast(GMenuModel*) __p); 224 } 225 226 /** 227 * Gets the popover that will be popped up when the dropdown is clicked. 228 * 229 * Returns: the popover 230 * 231 * Since: 1.0 232 */ 233 public Popover getPopover() 234 { 235 auto __p = adw_split_button_get_popover(adwSplitButton); 236 237 if(__p is null) 238 { 239 return null; 240 } 241 242 return ObjectG.getDObject!(Popover)(cast(GtkPopover*) __p); 243 } 244 245 /** 246 * Gets whether an underline in the text indicates a mnemonic. 247 * 248 * Returns: whether an underline in the text indicates a mnemonic 249 * 250 * Since: 1.0 251 */ 252 public bool getUseUnderline() 253 { 254 return adw_split_button_get_use_underline(adwSplitButton) != 0; 255 } 256 257 /** 258 * Dismisses the menu. 259 * 260 * Since: 1.0 261 */ 262 public void popdown() 263 { 264 adw_split_button_popdown(adwSplitButton); 265 } 266 267 /** 268 * Pops up the menu. 269 * 270 * Since: 1.0 271 */ 272 public void popup() 273 { 274 adw_split_button_popup(adwSplitButton); 275 } 276 277 /** 278 * Sets the child widget. 279 * 280 * Params: 281 * child = the new child widget 282 * 283 * Since: 1.0 284 */ 285 public void setChild(Widget child) 286 { 287 adw_split_button_set_child(adwSplitButton, (child is null) ? null : child.getWidgetStruct()); 288 } 289 290 /** 291 * Sets the direction in which the popup will be popped up. 292 * 293 * Params: 294 * direction = the direction 295 * 296 * Since: 1.0 297 */ 298 public void setDirection(GtkArrowType direction) 299 { 300 adw_split_button_set_direction(adwSplitButton, direction); 301 } 302 303 /** 304 * Sets the name of the icon used to automatically populate the button. 305 * 306 * Params: 307 * iconName = the icon name to set 308 * 309 * Since: 1.0 310 */ 311 public void setIconName(string iconName) 312 { 313 adw_split_button_set_icon_name(adwSplitButton, Str.toStringz(iconName)); 314 } 315 316 /** 317 * Sets the label for @self. 318 * 319 * Params: 320 * label = the label to set 321 * 322 * Since: 1.0 323 */ 324 public void setLabel(string label) 325 { 326 adw_split_button_set_label(adwSplitButton, Str.toStringz(label)); 327 } 328 329 /** 330 * Sets the menu model from which the popup will be created. 331 * 332 * Params: 333 * menuModel = the menu model 334 * 335 * Since: 1.0 336 */ 337 public void setMenuModel(MenuModel menuModel) 338 { 339 adw_split_button_set_menu_model(adwSplitButton, (menuModel is null) ? null : menuModel.getMenuModelStruct()); 340 } 341 342 /** 343 * Sets the popover that will be popped up when the dropdown is clicked. 344 * 345 * Params: 346 * popover = the popover 347 * 348 * Since: 1.0 349 */ 350 public void setPopover(Popover popover) 351 { 352 adw_split_button_set_popover(adwSplitButton, (popover is null) ? null : popover.getPopoverStruct()); 353 } 354 355 /** 356 * Sets whether an underline in the text indicates a mnemonic. 357 * 358 * Params: 359 * useUnderline = whether an underline in the text indicates a mnemonic 360 * 361 * Since: 1.0 362 */ 363 public void setUseUnderline(bool useUnderline) 364 { 365 adw_split_button_set_use_underline(adwSplitButton, useUnderline); 366 } 367 368 /** 369 * Emitted to animate press then release. 370 * 371 * This is an action signal. Applications should never connect to this signal, 372 * but use the [signal@SplitButton::clicked] signal. 373 * 374 * Since: 1.0 375 */ 376 gulong addOnActivate(void delegate(SplitButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 377 { 378 return Signals.connect(this, "activate", dlg, connectFlags ^ ConnectFlags.SWAPPED); 379 } 380 381 /** 382 * Emitted when the button has been activated (pressed and released). 383 * 384 * Since: 1.0 385 */ 386 gulong addOnClicked(void delegate(SplitButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 387 { 388 return Signals.connect(this, "clicked", dlg, connectFlags ^ ConnectFlags.SWAPPED); 389 } 390 }